{* $Id$ *}
{include_core file="admin/lib/header.html" title="核销记录"}
  <div class="page-header border-bottom clearfix">
    <h2 class="left">核销记录管理<span>在这里对核销记录进行管理</span></h2>
    <a style="margin-top:5px; display:block; float:right;" href="{AnUrl('store_verify_vocher_record/admin/download_list')}?search_filter[discount_code]={$search_filter.discount_code}&search_filter[group_platform_name]={$search_filter.group_platform_name}&search_filter[user_name]={$search_filter.user_name}&search_filter[store_name]={$search_filter.store_name}&search_filter[goods_name]={$search_filter.goods_name}&search_filter[start_date]={$search_filter.start_date}&search_filter[end_date]={$search_filter.end_date}&search_filter[exchange_start_date]={$search_filter.exchange_start_date}&search_filter[exchange_end_date]={$search_filter.exchange_end_date}&search_filter[expired_start_date]={$search_filter.expired_start_date}&search_filter[expired_end_date]={$search_filter.expired_end_date}&status={$status}" class="btn btn-xs btn-primary js_downList">导出EXCEL</a>
  </div>
  <div class="search-level1 clearfix">
    <form action="store_verify_vocher_record/admin" method="get">
      <input type="hidden" name="is_advenced" value="0" {if $is_advenced == 1}style="display:none;"{/if}>
      <input type="hidden" name="status" value="{$status}" {if $is_advenced == 1}style="display:none;"{/if}>
      <input type="text" class="left" name="search_filter[discount_code]" value="{$search_filter.discount_code}" placeholder="此处输入优惠码" {if $is_advenced == 1}style="display:none;"{/if}>
      <button type="submit" class="btn btn-success btn-sm left" {if $is_advenced == 1}style="display:none;"{/if}>搜索</button>
      <a href="javascript:void(0);" class="close js_advanced {if $is_advenced == 1}js_isOpen open{/if}">高级搜索<em></em></a>
    </form>
  </div>
  <div class="search-form js_advancedForm" {if $is_advenced == 0}style="display:none;"{/if}>
    <form action="{AnUrl('store_verify_vocher_record/admin')}" method="get" class="js_orderSearchForm">
      <input type="hidden" name="status" value="{$status}">
      <input type="hidden" name="is_advenced" value="1">
      <p>
        <label for="" class="search-f-label">优惠码：</label>
        <input type="text" class="search-f-ipt1" name="search_filter[discount_code]" value="{$search_filter.discount_code}">
      </p>
      <p>
        <label for="" class="search-f-label">平台名称：</label>
        <input type="text" class="search-f-ipt1" name="search_filter[group_platform_name]" value="{$search_filter.group_platform_name}">
      </p>
      <!-- <p>
        <label for="" class="search-f-label">商店名称：</label>
        <input type="text" class="search-f-ipt1" name="search_filter[store_name]" value="{$search_filter.store_name}">
      </p>
      <p>
        <label for="" class="search-f-label">商品名称：</label>
        <input type="text" class="search-f-ipt1" name="search_filter[goods_name]" value="{$search_filter.goods_name}">
      </p>
      <p> -->
        <label for="" class="search-f-label">用户名称：</label>
        <input type="text" class="search-f-ipt1" name="search_filter[user_name]" value="{$search_filter.user_name}">
      </p>
      <!-- <p>优惠码:</p> -->
      <p>
      <label for="" class="search-f-label">核销时间：</label>
        <input type="text" class="search-f-ipt1 search-f-ipt2" name="search_filter[start_date]" value="{$search_filter.start_date}" id="startDate">
        <span class="search-f-line"></span>
        <input type="text" class="search-f-ipt1 search-f-ipt2" name="search_filter[end_date]" value="{$search_filter.end_date}" id="stopDate">
      </p>
      <!--  <p>
      <label for="" class="search-f-label">->使用时间：</label>
        <input type="text" class="search-f-ipt1 search-f-ipt2" name="search_filter[exchange_start_date]" value="{$search_filter.exchange_start_date}" id="exchangeStartDate">
        <span class="search-f-line"></span>
        <input type="text" class="search-f-ipt1 search-f-ipt2" name="search_filter[exchange_end_date]" value="{$search_filter.exchange_end_date}" id="exchangeStopDate">
      </p>
      <p>
      <label for="" class="search-f-label">->过期时间：</label>
        <input type="text" class="search-f-ipt1 search-f-ipt2" name="search_filter[expired_start_date]" value="{$search_filter.expired_start_date}" id="expiredStartDate">
        <span class="search-f-line"></span>
        <input type="text" class="search-f-ipt1 search-f-ipt2" name="search_filter[expired_end_date]" value="{$search_filter.expired_end_date}" id="expiredStopDate">
      </p> -->
      <p><label for="" class="search-f-label"></label><button type="submit" class="btn btn-success btn-xs js_searchBtn">搜索</button></p>
    </form>
  </div>
  <!--start:列表-->
  <table class="list-table goods-table">
    <caption>按状态：
      <a href="{AnUrl("store_verify_vocher_record/admin?status=1")}" {if $status == 1} class="label label-primary" {else} class="label label-default" {/if}>正常</a>
      <a href="{AnUrl("store_verify_vocher_record/admin?status=0")}" {if $status == 0} class="label label-primary" {else} class="label label-default" {/if}>已删除</a>
    </caption>
    <thead>
      <tr>
        <th style="min-width:150px;">优惠码</th>
        <th style="min-width:120px;">平台名称</th>
        <th style="width:40px;">用户名</th>
        <th style="width:40px;">商店名</th>
        <th style="width:50px;">商品名</th>
        <th style="width:30px;">抵价</th>
        <th style="min-width:100px;">核销时间</th>
        <th>操作</th>
      </tr>
    </thead>
    <tbody>
      {foreach $record_list as $k=>$v}
        <tr id="dataList{$v.id}">
          <td>{$v['discount_code']}</td>
          <td>{$v['group_platform_name']}</td>
          <!-- @TODO 用户名未知 -->
          <td>{$v['user_name']}</td>
          <!-- @TODO 商店名未知 -->
          <td>{$v['store_name']}</td>
          <!-- @TODO 商品名未知 -->
          <td>{$v['goods_name']}</td>
          <td>{$v['worth']}</td>
          <td>{$v['add_time']}</td>
          <td>
            <a href="{AnUrl("store_verify_vocher_record/admin/show_detail?id={$v.id}")}" class="btn btn-info btn-xs"><i class="icon-edit icon-white js_showDetail"></i>详细信息</a>
            {if $v['status'] == 1}
              <a href="{AnUrl("store_verify_vocher_record/admin/delete?id={$v.id}")}" class="btn btn-danger btn-xs js_deleteOne"><i class="icon-trash icon-white"></i>删除</a> 
            {elseif $v['status'] == 0}
              <a href="{AnUrl("store_verify_vocher_record/admin/change_status?id={$v.id}")}" class="btn btn-success btn-xs js_changeStatus"><i class="icon-trash icon-white"></i>还原</a>
              <!-- <a href="{AnUrl("store_verify_vocher_record/admin/delete_group_platform?id={$v.id}")}" class="btn btn-danger btn-xs js_deleteOneGroupSeller"><i class="icon-trash icon-white"></i>彻底</a> -->
            {/if}
          </td>
        </tr>
      {foreachelse}
        <tr><td class="txtleft" colspan="8">暂无数据</td></tr>
      {/foreach}
    </tbody>
  </table>
  
  {include_core file="admin/lib/pager.html"}
<!--end:列表-->
<script>
$(function(){
  
  // 高级搜索
    $('.js_advanced').click(function(e){
      e.preventDefault();
      var thisObj = $(this);
      var outBox  = thisObj.closest('form');
      if (thisObj.hasClass('js_isOpen')) {
        thisObj.removeClass('js_isOpen open');
        outBox.find('input').show();
        outBox.find('button').show();
        $('.js_advancedForm').hide();
      } else {
        thisObj.addClass('js_isOpen open');
        outBox.find('input').hide();
        outBox.find('button').hide();
        $('.js_advancedForm').show();
      }
    });

  // 高级搜索时间验证
    $('.js_searchBtn').click(function(e){
      e.preventDefault();
      var thisObj           = $(this);
      var startDate         = $.trim($('#startDate').val());
      var exchangeStartDate = $.trim($('#exchangeStartDate').val());
      var expiredStartDate  = $.trim($('#expiredStartDate').val());
      var stopDate          = $.trim($('#stopDate').val());
      var exchangeStopDate  = $.trim($('#exchangeStopDate').val());
      var expiredStopDate   = $.trim($('#expiredStopDate').val());
      if (startDate > stopDate || exchangeStartDate > exchangeStopDate || expiredStartDate > expiredStopDate) {
        showMsg('结束时间应大于等于开始时间');
        return;
      }
      thisObj.closest('form').submit();
    });


  //单个删除
    $(".js_deleteOne").live('click',function(e){
      e.preventDefault();
      e.stopPropagation();
      var selectId = $(this).closest("tr").attr("id").substring(8);
      var roleId = $(this).closest("tr").data("id");
      if (!selectId) {
        alert('请选择要操作记录');
      }
      
      var clickObj = $(this);
      var url = clickObj.attr("href");
      var cardListBox = clickObj.closest('.cardListBox');
      var lines = $(this).parent().attr('rowspan');
      showConfirm('确定要删除此条记录吗？', 1, function(){
        $.post(url, {  'id':selectId }, function(json){
          if (json.info != 'ok') {
            alert(json.info);
          } else {
            clickObj.closest("tr").fadeOut(function(){
              if (lines) {
                for (var i = 1; i < lines; i++) {
                  $(this).next().remove();
                }
              };
              $(this).remove();
              interLineColor();
              
              if (cardListBox) {
                var trNum = cardListBox.find('.js_deleteOne').length;
                var level_total = cardListBox.attr('data-level_total');
                consoleLog(trNum);
                consoleLog(level_total);
                if (trNum < level_total) {
                  $('.addCard').show();
                }
              }
            });
          }
        }, 'json');
      });
      return false;
    });

  // added by ninghx 2012-07-31 将页面中的时间插件转移到公用的js中
  $('#exchangeStartDate, #exchangeStopDate, #expiredStartDate, #expiredStopDate').datepicker({
    dateFormat: 'yy-mm-dd',
    showButtonPanel: true,
    yearRange: '1900:'+new Date().getFullYear(),
    changeYear:true,
    changeMonth:true,
    maxDate: new Date(),
    yearSuffix: ''
  });
});
</script>
{include_core file="admin/lib/footer.html"}